package com.yunfeng.supercall.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.TextView;

import com.lin.activity.FriendsShareDynamicActivity;
import com.lin.activity.FriendsShareWallActivity;
import com.lin.activity.SuperFriendsNearByActivity;
import com.yunfeng.supercall.R;
import com.yunfeng.supercall.activity.FriendShareListActivity;
import com.yunfeng.supercall.activity.ShareActivity;
import com.yunfeng.supercall.activity.SuperSchoolActivity;
import com.yunfeng.supercall.bean.ContactsBaseBean;
import com.yunfeng.supercall.bean.SystemContactsBean;

public class ShareFragment extends BaseStickyHeaderListFragment<SystemContactsBean> {

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onViewCreated(view, savedInstanceState);
		setTextViewText(R.id.title, getString(R.string.share));
		findViewById(R.id.side_bar).setVisibility(View.GONE);
		SwipeRefreshLayout mRefreshLayout = findViewById(R.id.swipe);
		mRefreshLayout.setEnabled(false);
	}

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		// TODO Auto-generated method stub
		position = position - mListView.getHeaderViewsCount();
		if (position == 0) {
			startActivity(new Intent(getActivity(), FriendsShareWallActivity.class));
		}
		if (position == 1) {
/*			startActivity(new Intent(getActivity(),
					FriendShareListActivity.class));*/
			startActivity(new Intent(getActivity(),
					FriendsShareDynamicActivity.class));
		}
		if (position == 2) {
			startActivity(new Intent(getActivity(),
					SuperSchoolActivity.class).putExtra(KEY_DATA, -1));
			/*startActivity(new Intent(getActivity(),
					FriendsShareActivity.class).putExtra(KEY_DATA, -1));*/
			
		}
		if (position == 3) {
			/*startActivity(new Intent(getActivity(),
					FriendsShareActivity.class).putExtra(KEY_DATA, -2));*/
			startActivity(new Intent(getActivity(),
					SuperFriendsNearByActivity.class).putExtra(KEY_DATA, -2));
		}
	}

	@Override
	public void loadData() {
		// TODO Auto-generated method stub
		mList.clear();
		mList.addAll(SystemContactsBean.getShareSystemContactsList(getActivity()));
		setListAdapter();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null) {
			convertView = getActivity().getLayoutInflater().inflate(
					R.layout.list_item_system_friends, null);
		}
		ContactsBaseBean.setupSingleLineContactsView(convertView,
				mList.get(position));
		return convertView;
	}

	@Override
	public View getHeaderView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (position == 0) {
			// convertView = getInflater().inflate(R.layout.list_header_ads,
			// parent,false);
			// TextView tv = (TextView) convertView.findViewById(R.id.content);
			//
			// tv.setText("哈哈");
			// return convertView;
			return new View(getActivity());
		} else {
			TextView tv = (TextView) super.getHeaderView(position, convertView,
					parent);
			tv.setText("");
			return tv;
		}
	}

}
